package com.study.d4_sort;

public class SelectSort {
    public static void main(String[] args) {
        int[] arr ={10,12,3,8,5,1};
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }
        for (int i = 0; i < arr.length-1 ; i++) {
            //优化选择排序
            int minNum_index = i;
            for (int j = i+1; j < arr.length; j++) {
                if(arr[minNum_index]>arr[j]){
//                    int temp = arr[i];
//                    arr[i] = arr[j];
//                    arr[j] = temp;
                    minNum_index=j;
                }
            }
            if(minNum_index!=i) {
                int temp = arr[i];
                arr[i] = arr[minNum_index];
                arr[minNum_index] = temp;
            }
        }
        System.out.println("------");
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }
    }
}
